Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-512

TurboFilterAttachableImpl.addTurboFilter() will behave funny if newFilter.turboNext != null

    XMLWordPrintable

Details

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 0.9.14
    • None
    • None
    • None

    Description

      Hi!

      addTurboFilter() sets tailFilter incorrectly if newFilter.nextFilter != null

      Here's what I was trying to do.
      I implement a new TurboFilter.

      This TurboFilter is an interceptor that captures log messages and stores them for analysis.
      This is part of Unit Test. This Unit Test has to ensure that a specific message has been logged.

      This TurboFilter is not configured via logback.xml
      It can be but I don't want that to be mandatory.

      Instead this TurboFilter needs to bind itself to LoggerContext programmatically, via Logback API.
      It also need to bind itself as the first filter in the chain.

      Here's how I've tried to do it:

      final LogbackMessageProducer nuvo = new LogbackMessageProducer(true);

      /* make sure we're the first in the chain */
      final TurboFilter oldFirst = tfa.getFirstTurboFilter();
      nuvo.setNext(oldFirst);

      tfa.clearAllTurboFilters();
      tfa.addTurboFilter(nuvo);

      However should somebody else call addTurboFilter(some-other-filter) after this behavior shall be funny.
      Basically all old turbo filters that were bound before my code executed shall be lost.

      Attachments

        Activity

          People

            logback-dev Logback dev list
            atagunov Anton Tagunov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: